<template>
<div>
    <h1>康复理疗信息页</h1>
    <table class="table">
        <tr>
            <td>项目名称</td>
            <td><input type="text" v-model="data.kname"></td>
        </tr>

        <tr>
            <td>菜谱编码</td>
            <td><input type="text" v-model="data.kBma"></td>
        </tr>

        <tr>
            <td>佣金(元)</td>
            <td><input type="text" v-model="data.kMoney"></td>
        </tr>


        <tr>
            <td>服务人数</td>
            <td><input type="text" v-model="data.kcount"></td>
        </tr>

        <tr>
            <td>服务时长</td>
            <td><input type="text" v-model="data.kdate"></td>
        </tr>

        <tr>
            <td>项目说明</td>
            <td><input type="text" v-model="data.kMessage"></td>
        </tr>

        <tr>
            <td>状态</td>
            <td><input type="text" v-model="data.zt"></td>
        </tr>

        <tr>
            <td></td>
            <td><input type="button" value="添加" @click="Add()"></td>
        </tr>

    </table>
</div>

</template>

<script setup lang="ts">
import {ref,onMounted, pushScopeId} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter()



const data=ref({
       "id": 0,
  "kname": "",
  "kBma": "",
  "kMoney": 0,
  "kcount": 0,
  "kdate": 0,
  "kMessage": "",
  "zt": 0,
  "isDeleted": true
})

const Add=()=>{

    if(data.value.kname==""){
        alert("项目名称不能为空值");
        return
    }

    if(data.value.kMoney==0){
        alert("佣金(元)不能为空值");
        return
    }

    if(data.value.kcount==0){
        alert("服务人数不能为空值");
        return
    }

    if(data.value.kdate==0){
        alert("服务时长不能为空值");
        return
    }

    if(data.value.kcount*0!=0||data.value.kcount.toString().indexOf('.')>=0){
        alert("服务人数必须是整数");
        return
    }

    if(data.value.kdate*0!=0||data.value.kdate.toString().indexOf('.')>=0){
        alert("服务时长必须是整数");
        return
    }

    axios.post("/api/KangFu/KAdd",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push("/KShow")
        }else{
            alert("添加失败");
        }
    })
}


        
</script>

<style lang="scss" scoped>

</style>